package com.gs.zsmanage.utils;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

/**
 * Created with IntelliJ IDEA.
 * User: Legolas
 * Date: 2017/10/11 0011
 */
public class HttpUtils {

    //controller返回：
    // return HttpUtils.buildStringResponse("success",HttpStatus.OK);
    //OK(200, "OK"),
    //BAD_REQUEST(400, "Bad Request"),
    //NOT_FOUND(404, "Not Found"),
    //METHOD_NOT_ALLOWED(405, "Method Not Allowed"),
    //NOT_ACCEPTABLE(406, "Not Acceptable"),
    //INTERNAL_SERVER_ERROR(500, "Internal Server Error"),
    public static ResponseEntity<String> buildStringResponse(String str, HttpStatus status) {
        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.set("Content-Type", "text/plain;charset=utf-8;");
        return new ResponseEntity<>(str, responseHeaders, status);
    }

    public static ResponseEntity<String> buildOKResponse(String str) {
        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.set("Content-Type", "text/plain;charset=utf-8;");
        return new ResponseEntity<>(str, responseHeaders, HttpStatus.OK);
    }

    public static ResponseEntity<String> buildOKResponse() {
        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.set("Content-Type", "text/plain;charset=utf-8;");
        return new ResponseEntity<>("操作成功", responseHeaders, HttpStatus.OK);
    }


}
